{% extends 'base_children.html' %}

{% block content %}
    <div class="layui-row larryms-panel auth-user-add">
     <form action="{% url 'api_idc' %}" class="layui-form layui-form-pane" method="post" id="demoAddForm">
            {% csrf_token %}
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">机房名称</label>
                        <div class="layui-input-block">
                            <input class="layui-input" name="name" lay-verify="required" placeholder="请输入用户名"
                                   type="text">
                        </div>
                    </div>

                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">机房地址</label>
                    <div class="layui-input-block">
                        <input class="layui-input" name="address" placeholder="请输入地址" type="text">
                    </div>
                </div>
                <div class="layui-form-item">

                    <div class="layui-inline">
                        <label class="layui-form-label">电话</label>
                        <div class="layui-input-block">
                            <input class="layui-input" name="tel" placeholder="请输入电话" type="text">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">客户经理</label>
                        <div class="layui-input-block">
                            <input class="layui-input" name="contact" placeholder="经理名字" type="text">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">手机</label>
                        <div class="layui-input-block">
                            <input class="layui-input" name="contact_phone" lay-verify="phone" placeholder="请输入手机"
                                   type="text">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">机柜</label>
                        <div class="layui-input-block">
                            <input class="layui-input" name="jigui" placeholder="机柜" type="text">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">IP范围</label>
                        <div class="layui-input-block">
                            <input class="layui-input" name="ip_range" placeholder="IP范围" type="text">
                        </div>
                    </div>

                    <div class="layui-inline">
                        <label class="layui-form-label">接入带宽</label>
                        <div class="layui-input-block">
                            <input class="layui-input" name="bandwidth" placeholder="带宽" type="text">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">起租日</label>
                        <div class="layui-input-block">
                            <input class="layui-input" name="start_date" placeholder="" type="date">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">到期日</label>
                        <div class="layui-input-block">
                            <input class="layui-input" name="end_date" placeholder="点击选择" type="date">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">费用</label>
                        <div class="layui-input-block">
                            <input class="layui-input" name="cost" placeholder="金额" type="text">
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">机房类型</label>
                    <div class="layui-input-block">
                        <select name="type">
                            <option value=""></option>
                            <option value="自建">自建</option>
                            <option value="电信">电信</option>
                            <option value="联通">联通</option>
                            <option value="移动">移动</option>
                            <option value="BGP" selected="">BGP</option>
                        </select>

                    </div>
                </div>
                <div class="larryms-layer-btn">
                    <a class="layui-btn layui-btn layui-btn-sm left" lay-submit="" lay-filter="demoadd" id="submitAdd">确定</a>
                    <a class="layui-btn layui-btn layui-btn-sm  layui-btn-danger" id="resetAdd">重置</a>
                    <a class="layui-btn layui-btn layui-btn-sm  layui-btn-danger" id="closeAdd">关闭</a>
                </div>


            </form>
        </div>

{% endblock %}
{% block self_foot %}
<script type="text/javascript">
    layui.config({
        version: "2.0.8",
        base: '/static/larryms/',
         layertype: 2, //iframe内层弹窗类型不显示返回首页
        rightMenu: false // false关闭，设置为custom时使用自定义，不使用默认menu
    }).extend({
        larry: 'js/base'
    }).use(['larry','layer','form'], function() {
        var $ = layui.$,
            larry = layui.larry,
            table = layui.talbe,
            larryms = layui.larryms,
            form = layui.form;
        var curIfr = parent.layer.getFrameIndex(window.name);
        $('#resetAdd').on('click', function() {
            $('#demoAddForm')[0].reset();
        });
        $('#closeAdd').on('click', function() {
            parent.layer.close(curIfr);
        });
        form.on('submit(demoadd)', function(data) {
            $.post(data.form.action, data.field, function(res) {
                if (res.code == 200) {
                    {#larryms.msg(res.msg);#}
                    {#parent.table.reload('demo', {}); //刷新tableid ,中括号是针对分页，刷新某一页的数据时使用#}
                    {#parent.layer.close(curIfr);#}
                    {#// $('#demoAddForm')[0].reset();继续添加注销上一段#}
                    larryms.msg(res.msg,{time:350},function () {
                        parent.table.reload('demo',{});
                        parent.layer.close(curIfr);
                    })

                } else if (res.code == 911) {
                    larryms.msg(res.msg);
                } else if (res.code == 500) {
                    larryms.msg(res.msg);
                }
            });
            return false;
        });

    });


    </script>

{% endblock %}